package com.fr.chart;

import com.fr.base.FRFont;
import com.fr.base.XMLable;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.axis.TextAttr;
import com.fr.chart.base.equals.Equals;
import com.fr.chart.core.glyph.TextGlyph;
import com.fr.report.io.xml.ReportXMLUtils;
import com.fr.util.Utils;

public class Title extends ChartModule
  implements XMLable
{
  private static final long serialVersionUID = 1L;
  public static final String XML_TAG = "Title";
  private Object text = "";
  private TextAttr textAttr = new TextAttr();
  private boolean titleVisble = true;

  public Title()
  {
    FRFont localFRFont = FRFont.getInstance();
    localFRFont = localFRFont.applyStyle(3);
    this.textAttr.setFRFont(localFRFont);
  }

  public Title(Object paramObject)
  {
    setTextObject(paramObject);
  }

  public TextGlyph createGlyph()
  {
    if (!(getTitleVisble()))
      return null;
    String str = Utils.objectToString(this.text);
    TextGlyph localTextGlyph = new TextGlyph(str, this.textAttr);
    localTextGlyph.setInfo(getInfo());
    return localTextGlyph;
  }

  public Object getTextObject()
  {
    return this.text;
  }

  public void setTextObject(Object paramObject)
  {
    this.text = paramObject;
  }

  public void setTextAttr(TextAttr paramTextAttr)
  {
    this.textAttr = paramTextAttr;
  }

  public TextAttr getTextAttr()
  {
    return this.textAttr;
  }

  public void setTitleVisble(boolean paramBoolean)
  {
    this.titleVisble = paramBoolean;
  }

  public boolean getTitleVisble()
  {
    return this.titleVisble;
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    Title localTitle = (Title)super.clone();
    if (getTextAttr() != null)
      localTitle.setTextAttr((TextAttr)getTextAttr().clone());
    return localTitle;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str1 = paramXMLableReader.getTagName();
      if ("O".equals(str1))
      {
        this.text = ReportXMLUtils.readObject(paramXMLableReader);
      }
      else if ("TextAttr".equals(str1))
      {
        this.textAttr = new TextAttr();
        paramXMLableReader.readXMLObject(this.textAttr);
      }
      else if ("TitleVisible".equals(str1))
      {
        String str2;
        if ((str2 = paramXMLableReader.getAttr("value")) != null)
          setTitleVisble(Boolean.valueOf(str2).booleanValue());
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("Title");
    super.writeXML(paramXMLPrintWriter);
    if (this.text != null)
      ReportXMLUtils.writeObject(paramXMLPrintWriter, this.text);
    if (this.textAttr != null)
      this.textAttr.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.startTAG("TitleVisible").attr("value", this.titleVisble).end();
    paramXMLPrintWriter.end();
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof Title))
      return false;
    Title localTitle = (Title)paramObject;
    if (!(super.equals(localTitle)))
      return false;
    if (!(Equals.equals(localTitle.getTextObject(), getTextObject())))
      return false;
    if (!(Equals.equals(localTitle.getTextAttr(), getTextAttr())))
      return false;
    return (localTitle.getTitleVisble() == getTitleVisble());
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = super.toJSONObject();
    if (this.textAttr != null)
      localJSONObject.put("textAttr", this.textAttr.toJSONObject());
    localJSONObject.put("text", this.text);
    localJSONObject.put("titleVisble", this.titleVisble);
    return localJSONObject;
  }
}